<!--
 * @Date: 2019-11-18 14:39:13
 * @LastEditors: Vi卡农
 * @LastEditTime: 2019-11-18 15:17:15
 * @describe: -地铁线路
 -
 -->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-dictionary__metro}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.name" placeholder="线路名" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <!-- <el-form-item>
          <el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>
        </el-form-item> -->
        <el-form-item>
          <el-button v-if="$hasPermission('dictionary:metro:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
        <!-- <el-form-item>
          <el-button v-if="$hasPermission('dictionary:metro:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item> -->
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;" stripe>
        <!-- <el-table-column prop="id" label="" header-align="center" align="center" width="70"></el-table-column> -->
        <el-table-column prop="name" label="名称" header-align="center" align="center" width="150"></el-table-column>
        <el-table-column prop="status" label="状态" header-align="center" align="center" width="100">
          <template slot-scope="scope">
            <span v-if="scope.row.status==1">
              正常
            </span>
            <span v-else>
              停用
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="metroStation" label="站点" header-align="center">
          <template slot-scope="scope">
            <span v-for="(item,index) in scope.row.metroStation" class="metroStationItem">
              {{item.stationName}}
            </span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('dictionary:metro:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">编辑</el-button>
            <el-button v-if="$hasPermission('dictionary:metro:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="ZWbox"></div>
      <div class="paginationBox">
      <el-pagination
        :current-page="page"
        :page-size="limit"
        :total="total"
        layout="total, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      </div>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './metro-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/dictionary/metro/page',
        getDataListIsPage: true,
        // exportURL: '/dictionary/metro/export',
        deleteURL: '/dictionary/metro',
        deleteIsBatch: true
      },
      dataForm: {
        name: ''
      },
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
<style scoped lang="scss">
  .metroStationItem{
    margin-right: 10px;
  }
</style>